home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
The World of Computer Software.iso
/
vsc92nov.zip
/
sym-prim.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-11-02
|
2KB
|
69 lines
/*
* sym-prim.c -- Implementation of Scheme's primitive symbol procedures
*
* (C) m.b (Matthias Blume), Mon Jun 1 12:50:35 MET DST 1992, HUB/Ger
* Humboldt-University of Berlin, Germany
*/
# ident "@(#)sym-prim.c (C) M.Blume, Humboldt-Uni Berlin, 1.2"
# include <stdlib.h>
# include <string.h>
# include "storage.h"
# include "Cont.h"
# include "Symbol.h"
# include "String.h"
# include "Boolean.h"
# include "type.h"
# include "except.h"
# include "tmpstring.h"
# include "builtins.tab"
/*ARGSUSED*/
void ScmPrimitiveSymbolP (unsigned short argcnt)
{
void *tmp = ScmPeek();
ScmSetTop (ScmTypeOf (tmp) == ScmType (Symbol)
? &ScmTrue
: &ScmFalse);
}
/*ARGSUSED*/
void ScmPrimitiveSymbolToString (unsigned short argcnt)
{
void *tmp = ScmPeek();
ScmSymbol *sym;
ScmString *string;
unsigned len;
char *buf;
if (ScmTypeOf (tmp) != ScmType (Symbol))
error ("bad arg to primitive procedure symbol->string: %w", tmp);
sym = tmp;
buf = tmpstring (sym->array, sym->length);
len = sym->length;
string = getmem (ScmType (String), sizeof (ScmString) + len - 1);
string->length = len;
memcpy (string->array, buf, len);
ScmSetTop (string);
}
/*ARGSUSED*/
void ScmPrimitiveStringToSymbol (unsigned short argcnt)
{
void *tmp = ScmPeek();
ScmSymbol *sym;
ScmString *string;
char *buf;
if (ScmTypeOf (tmp) != ScmType (String))
error ("bad arg to primitive procedure string->symbol: %w", tmp);
string = tmp;
buf = tmpstring (string->array, string->length);
sym = ScmMakeSymbol (buf, string->length);
ScmSetTop (sym);
}